package cn.mistorange.service;


import cn.mistorange.mapper.CategoryMapper;
import cn.mistorange.pojo.Category;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class CategoryServiceImpl implements CategoryService{


    @Autowired
    private CategoryMapper categoryMapper;

    //查询类型
    @Override
    public List<Category> getAllCategories(String type) {
        return categoryMapper.getAllCategories(type);
    }

    //id查询
    @Override
    public Category getCategoryById(Integer id) {
        return categoryMapper.getByIdCategories(id);
    }

    //添加类型
    @Override
    public void addCategory(String name, String type) {
        categoryMapper.addCategory(name, type);
    }

    //删除类型
    @Override
    public void deleteCategory(Integer id) {
        categoryMapper.deleteCategory(id);
    }

    //修改

    @Override
    public void updateCategory(Integer id, String name, String type) {
        categoryMapper.updateCategory(id, name, type);
    }
}